package com.ruoyi.web.controller.fx;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.fx.FxWithdrawalAccount;
import com.ruoyi.system.service.fx.IFxWithdrawalAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 提现账号管理Controller
 * 
 * @author ruoyi
 * @date 2024-09-12
 */
@RestController
@RequestMapping("/fx/account")
public class FxWithdrawalAccountController extends BaseController
{
    @Autowired
    private IFxWithdrawalAccountService fxWithdrawalAccountService;

    /**
     * 查询提现账号管理列表
     */
    @GetMapping("/list")
    public AjaxResult list(FxWithdrawalAccount fxWithdrawalAccount)
    {
        List<FxWithdrawalAccount> list = fxWithdrawalAccountService.selectFxWithdrawalAccountList(fxWithdrawalAccount);
        return success(list);
    }

    /**
     * 查询当前用户提现账号列表
     */
    @GetMapping("/optionList")
    public AjaxResult optionList()
    {
        List<FxWithdrawalAccount> list = fxWithdrawalAccountService.optionList();
        return success(list);
    }


    /**
     * 导出提现账号管理列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxWithdrawalAccount fxWithdrawalAccount)
    {
        List<FxWithdrawalAccount> list = fxWithdrawalAccountService.selectFxWithdrawalAccountList(fxWithdrawalAccount);
        ExcelUtil<FxWithdrawalAccount> util = new ExcelUtil<FxWithdrawalAccount>(FxWithdrawalAccount.class);
        util.exportExcel(response, list, "提现账号管理数据");
    }

    /**
     * 获取提现账号管理详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(fxWithdrawalAccountService.selectFxWithdrawalAccountById(id));
    }

    /**
     * 新增提现账号管理
     */
    @PostMapping
    public AjaxResult add(@RequestBody FxWithdrawalAccount fxWithdrawalAccount)
    {
        return toAjax(fxWithdrawalAccountService.insertFxWithdrawalAccount(fxWithdrawalAccount));
    }

    /**
     * 修改
     * @return
     */
    @PostMapping("/editList")
    public AjaxResult editList(@RequestBody List<FxWithdrawalAccount> list) {
        fxWithdrawalAccountService.insertAccountLIst(list);
        return AjaxResult.success();
    }

    /**
     * 修改提现账号管理
     */
    @PutMapping
    public AjaxResult edit(@RequestBody FxWithdrawalAccount fxWithdrawalAccount)
    {
        return toAjax(fxWithdrawalAccountService.updateFxWithdrawalAccount(fxWithdrawalAccount));
    }

    /**
     * 删除提现账号管理
     */
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fxWithdrawalAccountService.deleteFxWithdrawalAccountByIds(ids));
    }
}
